#include <stdio.h>

void Coprime(int m,int n)
{
    int x,y,tmp;
    x=m;
    y=n;
    while(y){
        tmp=x;
        x=y;
        y=tmp%x;
    }
    if(x==1)
        printf("%d and %d are coprime.\n%d*%d=%d\n",m,n,m,n,m*n);
    else
        printf("gcd(%d,%d)=%d\nlcm(%d,%d)=%d\n",m,n,x,m,n,m*n/x);
}
int main()
{
    int m,n;
    printf("m n: ");
    scanf("%d%d",&m,&n);
    while(!(n&&m)){
        puts("Illegal input!");
        printf("m n: ");
        scanf("%d%d",&m,&n);
    }
    Coprime(m,n);
    return 0;
}
